import React from 'react'
import ReactDom from 'react-dom'
import { createStore, applyMiddleware, compose } from 'redux'
import thunk from 'redux-thunk'
import { Provider } from 'react-redux'
import { BrowserRouter, Route, Switch } from 'react-router-dom'

import './config'
import reducer from './reducer'
import Login from '@/containers/login'
import Register from '@/containers/register'
import Authorize from '@/components/Authorize'
import BossInformation from '@/containers/information/BossInformation'
import GeniusInformation from '@/containers/information/GeniusInformation'
import BasicLayout from '@/layouts/BasicLayout'
import ChatRoom from '@/containers/chatRoom'

const store = createStore(reducer, compose(
    applyMiddleware(thunk),
    window.__REDUX_DEVTOOLS_EXTENSION__ ? window.__REDUX_DEVTOOLS_EXTENSION__() : f => f
))

ReactDom.render((
    <Provider store={store}>
        <BrowserRouter>
            <Authorize/>
            <Switch>
                <Route path="/login" component={Login} />
                <Route path="/register" component={Register} />
                <Route path="/home" component={BasicLayout}/>
                <Route path="/chat/:id" component={ChatRoom} />
                <Route path="/information/genius" component={GeniusInformation} />
                <Route path="/information/boss" component={BossInformation} />
                <Route component={() => <h1>404</h1>}/>
            </Switch>
        </BrowserRouter>
    </Provider>
), document.getElementById('root'))




